home *** CD-ROM | disk | FTP | other *** search
/ The Very Best of Atari Inside / The Very Best of Atari Inside 1.iso / mint / mntlb20 / lib / setjmp.cpp < prev    next >
Text File  |  1990-09-25  |  848b  |  40 lines

  1. |
  2. | setjmp.cpp 
  3. |
  4.     .text
  5.     .even
  6.     .globl _setjmp
  7. _setjmp:
  8.     movel    sp@(4),a0        | address of jmp_buf[]
  9.     movel    sp@,a0@            | save return address
  10.     moveml    d2-d7/a2-a7,a0@(4)    | save registers d2-d7/a2-a7
  11.     clrl    d0            | return value is 0
  12.     rts
  13.  
  14.     .globl _longjmp
  15.     .globl ___mint
  16.  
  17. _longjmp:
  18. #ifdef __MSHORT__
  19.     tstw    ___mint            | see if MiNT is active
  20. #else
  21.     tstl    ___mint
  22. #endif
  23.     beq    NOMINT            | no -- do not call sigreturn
  24.     movew    #0x11a, sp@-        | Psigreturn() system call
  25.     trap    #1            | (ignored if not in a sig handler)
  26.     addqw    #2, sp
  27. NOMINT:
  28.     movel    sp@(4),a0        | address of jmp_buf[]
  29. #ifdef __MSHORT__
  30.     movew    sp@(8),d0        | value to return
  31. #else
  32.     movel    sp@(8),d0        | value to return
  33. #endif
  34.     bne    L1            | may not be 0
  35.     movl    #1, d0
  36. L1:
  37.     moveml    a0@(4),d2-d7/a2-a7    | restore saved reggies
  38.     movl    a0@,sp@            | and the saved return address
  39.     rts
  40.